using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SMS.Common;
using SMS.Framework;


namespace SMS.MdiWindow
{
    public partial class MessageForm : Form
    {
        public MessageForm()
        {
            InitializeComponent();
        }

        private void MessageForm_Load(object sender, EventArgs e)
        {
        }

        private void MessageForm_Activated(object sender, EventArgs e)
        {
            string messageId = (string)this.Tag;
            MessageEntry messageEntry = MessageEntry.GetMessageEntryById(messageId);
            lblId.Text = messageEntry.MessageId;
            lblCaption.Text = messageEntry.Caption;
            lblCategory.Text = messageEntry.Category;
            lblContent.Text = messageEntry.Content;
            lblDate.Text = messageEntry.EditDate.ToShortDateString();
            lblDepartment.Text = messageEntry.SenderDepartment;
            lblSender.Text = messageEntry.Sender;
            lblStatus.Text = messageEntry.Status;
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

        private void btnRead_Click(object sender, EventArgs e)
        {
            MessageEntry.MarkRead(lblId.Text.Trim());
            Context.Current.ExecuteApplicationCommand(sender, "UpdateMessageListBox", null);
        }
    }
}